package api

import (
	"fmt"
	"github.com/gin-gonic/gin"
	"goWebTest/goGinWebJwtTest/jwt"
	"net/http"
)

func Test(c *gin.Context) {

}

func Login(c *gin.Context) {

	fmt.Print("登陆")
	account := c.Query("account")
	if len(account) == 0 {
		c.JSON(http.StatusPaymentRequired, gin.H{"code": 0, "msg": "账号有误"})
		return
	}

	token, _ := jwt.GenerateToken(1, "admin", "大总管")
	c.JSON(http.StatusOK, gin.H{"code": 0, "msg": "登陆成功", "Data": token})
}

func Register(c *gin.Context) {
	fmt.Println("注册用户")
	c.JSON(http.StatusOK, gin.H{"code": 0, "Data": "注册用户成功"})
}

func UpdateUser(c *gin.Context) {

	fmt.Println("更新用户")
	c.JSON(http.StatusOK, gin.H{"code": 0, "Data": "更新用户成功"})
}

func Info(c *gin.Context) {

	fmt.Println("获取当前用户信息")
	c.JSON(http.StatusOK, gin.H{"code": 0, "Data": "获取当前用户信息成功"})
}
